
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            height: 2000px;
            background: red;
        }

        span{
            border-radius: 50%;
            color: #ffffff;
            background: #000000;
            width: 50px;
            height: 50px;
            display: block;
            text-align: center;
            line-height: 50px;
            position: fixed;
            top: 50%;
            right: 50px;
            border: solid 2px #ddd;
        }
    </style>
</head>
<body>
    <a id="aa">顶部</a>
    <div>hdcms.com</div>
    <h1>hoduuren.com</h1>
    <span>TOP</span>

    <script>
        document.querySelector('span').addEventListener('click',() => {
            let aa = document.querySelector('#aa');
            aa.scrollIntoView(true)
        });
    </script>
</body>
</html>